package 网络编程项目.login;


import 网络编程项目.login.entity.User;
import 网络编程项目.login.utiles.ImageUtil;
import 网络编程项目.util.PathUtils;

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class PersonalCenter {
  private JPanel center;
  private JLabel phoneLabel;
  private JLabel emailLabel;
  private JLabel useridValue;
  private JLabel usernameValue;
  private JLabel phoneValue;
  private JLabel emailValue;
  private JButton updateButton;
  private JButton back;
  private JLabel image;
  private JLabel ID;
  private JLabel username;

  public PersonalCenter() {
    back.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        DropOut.main();
      }
    });
  }

  private void setValue(User user) {
    useridValue.setText(user.getUserid());
    usernameValue.setText(user.getUsername());
    phoneValue.setText(user.getPhone());
    emailValue.setText(user.getEmail());
    ImageIcon icon = ImageUtil.change(new ImageIcon(PathUtils.imgDir+"/" + user.getImage() + ".jpg"), 100);
    image.setIcon(ImageUtil.change(icon, 120));
  }

  public static void main(User user) {
    JFrame frame = new JFrame("PersonalCenter");
    PersonalCenter center = new PersonalCenter();
    center.setValue(user);
    frame.setContentPane(center.center);
    frame.pack();
    frame.setVisible(true);
    frame.setLocation(300, 200);
    frame.setSize(1000, 300);
  }
}
